<template>
<div class="block">
    <el-tree
      :data="data"
      show-checkbox
      node-key="id"
      :props="defaultProps"
      :expand-on-click-node="false">
      <span class="custom-tree-node" slot-scope="{ node, data }">
        <span>{{ node.label }}</span>
        <span>
          <el-button
            type="text"
            size="mini"
            @click="() => append(data)">
            Append
          </el-button>
          <el-button
            type="text"
            size="mini"
            @click="() => remove(node, data)">
            Delete
          </el-button>
        </span>
      </span>
    </el-tree>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        data: [],
        defaultProps: {
          children: "children",
          label: "name"
        }
      }
    },
    methods: {
      append(data) {

      },

      remove(node, data) {

      },
      getMenu(){
        this.$http({
          url: this.$http.adornUrl('product/category/list/tree'),
          method: 'get',
          params: this.$http.adornParams({

          })
        }).then(({data}) => {
          this.data= data.data;
        })
      }
    },
    created () {
      this.getMenu();
    }
  }
</script>

